package com.sand.controller;

import com.alibaba.fastjson.JSON;
import com.sand.service.ICollectionService;
import com.sand.util.PageModel;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

@Controller
@RequestMapping(value = "collection")
public class CollectionController {

    @Resource(name = "collectionService")
    private ICollectionService collectionService;

    @RequestMapping(value = "/queryCollectionLimit")
    public void queryCollectionLimit(int limit, int page, String condition, HttpServletResponse response) throws Exception{
        response.setCharacterEncoding("utf-8");
        PageModel<HashMap<String, Object>> pm = collectionService.queryCollectionByUserIdLimit(limit, page, condition);
        response.getWriter().write(JSON.toJSON(pm).toString());
        System.out.println(JSON.toJSON(pm).toString());
    }
}
